package com.eshop.we.controller;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.eshop.we.area.entity.Area;
import com.eshop.we.business.AreaBusiness;
import com.eshop.we.result.Result;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@Api(value = "地区接口管理", description = "地区接口管理")
@RestController
@RequestMapping("/area")
public class AreaController extends BaseController{

    @Autowired
    AreaBusiness areaBusiness;


    @ApiOperation(value = "获取地区列表",notes = "获取地区列表")
    @ApiImplicitParams({
            @ApiImplicitParam(
                    name = "levelType",
                    required = true,
                    dataType = "Integer",
                    paramType = "query",
                    value = " 1:省:2:市: 3:县  ",
                    allowableValues = "",
                    allowMultiple = false
            ),
            @ApiImplicitParam(
                    name = "parentId",
                    required = false,
                    dataType = "Integer",
                    paramType = "query",
                    value = " 父级id",
                    allowableValues = "",
                    allowMultiple = false
            ),
            @ApiImplicitParam(
                    name = "areaId",
                    required = false,
                    dataType = "Integer",
                    paramType = "query",
                    value = " id",
                    allowableValues = "",
                    allowMultiple = false
            )

    })
    @GetMapping("/getarealist")
    public Result getAreaList(@ApiParam(value = "省市县级别", required = true)  @RequestParam(required = true) Integer levelType,
                              @ApiParam(value = "省市县父级", required = false)  @RequestParam(required = false) Integer parentId,
                              @ApiParam(value = "省市县id", required = false)  @RequestParam(required = false) Integer areaId){

        Area area=new Area();
        area.setLevelType(levelType);
        area.setParentId(parentId);
        area.setAreaId(areaId);
        EntityWrapper ew= new EntityWrapper<Area>();
        ew.setEntity(area);
       return Result.success(areaBusiness.selectList(ew));
    }


}
